function [dropPos]  = bomberFerguson(graph, shipPos, lastShipPos, pj, lag)
%% This function simulates the bomber by Ferguson.

dropPos = 0; %default no drop
persistent bomber_time;
if (sum(lastShipPos)==0)
    bomber_time = 0;
end
lastPos = [shipPos; lastShipPos(1:2)'];
if (length(unique(lastPos)) <= 2 && ~any(lastPos==0))  %A-B-A
    bomber_time = bomber_time + 1;
    tdrop = calcBomberTime(pj,sum(graph(1,:))); 
    %must the bomber drop the bomb?
    if (tdrop <= bomber_time) 
        %find all possible positions
        places = getBomberPlaces(graph, shipPos, lag, lastShipPos(1));
        %choose randomly one ot of it
        pla = randperm(length(places));    
        dropPos = places(pla(1)); 
		bomber_time = 0;
    end
    %start calculation
else %A-B-C 
    bomber_time = 0;
end
